home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "FTPSystem"
- '--------------------------------------------------------
- '<Purpose> provides support for a remote FTP system
- '--------------------------------------------------------
-
- Option Explicit
-
- '<Constant>----------------------------------------------
- Public Const ftpMaxSessions As Integer = 10
- '</Constant>---------------------------------------------
-
-
- '------------------------------------------------------------
- '<Purpose> populates the TreeView with FTP Servers that
- ' are designated to be "reconnected at logon"
- '------------------------------------------------------------
- Public Sub AddFTPServers(ThisExplorer As Form, ParentNode As Node)
- Dim DriveImage As Integer
- Dim InstanceServer As FTPServer
- Dim TheseNodes As Nodes
- Dim WorkingNode As Node
- Dim NodeKey As String
- Dim ParentKey As String
-
- ThisExplorer.MousePointer = vbArrowHourglass
-
- '---- errors can be generated from duplicate keys; ignore
- On Error Resume Next
-
- '---- cache nodes collection
- Set TheseNodes = ThisExplorer.Tree.Nodes
-
- ParentKey = ParentNode.Key & "."
-
- For Each InstanceServer In MapServers.Servers
- NodeKey = ParentKey & InstanceServer.Alias
-
- If (Not IsKeyed(TheseNodes, NodeKey)) Then
- If (InstanceServer.Reconnect = vbChecked) Then
- '---- add the node to the tree
- Set WorkingNode = TheseNodes.Add(ParentNode, tvwChild, NodeKey, InstanceServer.Alias, imgFTPDrive)
-
- '---- also create and add attachment
- Dim ThisAttachment As New Attachment
- Dim ThisSession As New Session
-
- ThisAttachment.NodeType = nodFTPServer
- Set ThisSession.ThisServer = InstanceServer
- Set ThisAttachment.Session = ThisSession
- ThisAttachment.DrivePath = "/"
- Call ThisExplorer.Attachments.Add(ThisAttachment, NodeKey)
-
- Set ThisSession = Nothing
- Set ThisAttachment = Nothing
-
- '---- add searching placeholder
- Call TheseNodes.Add(WorkingNode, tvwChild, WorkingNode.Key & nodPlaceHolder, nodPlaceHolder, imgPlaceHolder)
- End If
- End If
- Next
-
- Cleanup:
- On Error GoTo 0
-
- Set InstanceServer = Nothing
- Set TheseNodes = Nothing
- Set WorkingNode = Nothing
-
- ThisExplorer.MousePointer = vbDefault
- End Sub
-
- '--------------------------------------------------------
- '<Purpose> starts the process of getting FTP directories
- '--------------------------------------------------------
- Public Function ListFTPServer(ThisExplorer As Form, ServerNode As Node) As Boolean
- Dim ThisSession As Form
- Dim ThisAttachment As Attachment
-
- On Error GoTo BadSession
- Set ThisAttachment = ThisExplorer.Attachments.Item(ServerNode.Key)
- Set ThisSession = ThisAttachment.Session
-
- '---- create the session and set the callback
- With ThisSession
- Call .InitSession
- .WorkingDir = ThisAttachment.DrivePath
- Call .Connect
- Set .ServerNode = ServerNode
- Set .ThisExplorer = ThisExplorer
- Set .ThisCallback = New FTPCallback
- End With
-
- ListFTPServer = True
-
- Cleanup:
- On Error GoTo 0
- Set ThisSession = Nothing
- Set ThisAttachment = Nothing
- Exit Function
-
- BadSession:
- ListFTPServer = False
- GoTo Cleanup
- End Function
-
- Public Function ChangeFTPDir(Session As Form, DirName As String) As Boolean
-
- Session.MousePointer = vbArrowHourglass
-
- '---- a directory selection has been made
- '---- now update the listboxes
- If (DirName = "..") Then
- Session.ciSession.WorkingDirectory = ".."
- Session.ciSession.CWD
- ElseIf (DirName = ".") Then
- Session.ciSession.WorkingDirectory = "/"
- Session.ciSession.CWD
- Else
- Session.ciSession.WorkingDirectory = DirName
- Session.ciSession.CWD
- End If
-
- Session.ciSession.PWD
- Session.ciSession.PASV
-
- End Function
-
- '--------------------------------------------------------
- '<Purpose> maps an FTPServer to the Explorer
- '--------------------------------------------------------
- Public Function MapServer(ThisExplorer As Form) As Boolean
- Dim ParentNode As Node
- Dim ServerNode As Node
- Dim TheseNodes As Nodes
- Dim ThisSession As New Session
- Dim ServerKey As String
-
- With MapServers
- Set .ThisExplorer = ThisExplorer
- .Show vbModal
- If (Not .PressedOK) Then GoTo Cleanup
- End With
-
- '---- cache nodes collection
- Set TheseNodes = ThisExplorer.Tree.Nodes
-
- Set ThisSession.ThisServer = MapServers.ThisServer
-
- '---- add the node to the tree
- Set ParentNode = TheseNodes.Item("Root.FTPServers")
- ServerKey = ParentNode.Key & "." & ThisSession.ThisServer.Alias
-
- '---- may already be in TreeView, if not add it
- If (Not IsKeyed(TheseNodes, ServerKey)) Then
- Set ServerNode = TheseNodes.Add(ParentNode, tvwChild, ServerKey, ThisSession.ThisServer.Alias, imgFTPDrive)
-
- '---- add searching placeholder
- Call TheseNodes.Add(ServerNode, tvwChild, ServerNode.Key & nodPlaceHolder, nodPlaceHolder, imgPlaceHolder)
-
- '---- also create and add attachment
- Dim ThisAttachment As New Attachment
- ThisAttachment.NodeType = nodFTPServer
- Set ThisAttachment.Session = ThisSession
- Call ThisExplorer.Attachments.Add(ThisAttachment, ServerKey)
- Set ThisAttachment = Nothing
-
- End If
-
- Cleanup:
- Set ParentNode = Nothing
- Set TheseNodes = Nothing
- Set ThisSession = Nothing
- Set ServerNode = Nothing
-
- End Function
-